/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.serli.sample.peopleapp;

import com.serli.sample.person.model.data.Gender;
import com.serli.sample.person.model.data.Person;
import com.serli.sample.person.model.service.PeopleServiceClientFactory;
import com.serli.sample.person.model.service.PeopleServiceRemote;
import com.serli.sample.person.model.service.TypeService;
import javax.naming.NamingException;

//import com.serli.sample.person.model.service.ws.PeopleServiceWS;
/**
 *
 * @author serli
 */
public class CallPeopleService {

    public static void main(String args[]) throws NamingException {

         // Les POJOs Person et Gender sont déclarés dans l'API

        
        
//        PeopleServiceRemote service = new PeopleServiceClientFactory().getService(TypeService.SOA_WS_SOAP);
        PeopleServiceRemote service = new PeopleServiceClientFactory().getService(TypeService.SCA_EJB_Remote);

        System.out.println(service.getAllOrderByFirstName());

        try {
            System.out.println("TEST SetPerson");

            Person p = new Person();
            p.setFirstName("MERON");
            p.setLastName("Pascal");
            p.setBirthDateAsStr("1979-01-17");
            p.setGender(Gender.MALE);


            service.testRemoteSetPerson(p);
            System.out.println("\t[ OK ]");
        } catch (Exception ex) {
            System.out.println("\t[ ERROR ] : " + ex.getMessage());
        }
        try {
            System.out.println("TEST GetPerson");
            Person person = service.testRemoteGetPerson();
            System.out.println("firstName is " + person.getFirstName());
            System.out.println("\t[ OK ]");
        } catch (Exception ex) {
            System.out.println("\t[ ERROR ] : " + ex.getMessage());
        }
        try {
            System.out.println("TEST Set and Get simple object (Object)");
            service.testRemoteObject(new String("String test"));
            System.out.println("\t[ OK ]");
        } catch (Exception ex) {
            System.out.println("\t[ ERROR ] : " + ex.getMessage());
        }
        try {
            System.out.println("TEST Set and Get Primitif (int)");
            service.testRemotePrimitif(1979);
            System.out.println("\t[ OK ]");
        } catch (Exception ex) {
            System.out.println("\t[ ERROR ] : " + ex.getMessage());
        }
        try {
            System.out.println("TEST GetPerson");
            Person person = service.testRemoteGetPerson();
            System.out.println("firstName is " + person.getFirstName());
            System.out.println("\t[ OK ]");
        } catch (Exception ex) {
            System.out.println("\t[ ERROR ] : " + ex.getMessage());
        }
        try {
            System.out.println("TEST Set and Get simple object (Object)");
            service.testRemoteObject(new String("String test"));
            System.out.println("\t[ OK ]");
        } catch (Exception ex) {
            System.out.println("\t[ ERROR ] : " + ex.getMessage());
        }
        try {
            System.out.println("TEST Set and Get Primitif (int)");
            service.testRemotePrimitif(1979);
            System.out.println("\t[ OK ]");
        } catch (Exception ex) {
            System.out.println("\t[ ERROR ] : " + ex.getMessage());
        }
    }
}
